package com.hundunjiang.ToolsServer.server.Impl;

import com.hundunjiang.MbgServer.entity.VirtualAliases;
import com.hundunjiang.MbgServer.entity.VirtualUsers;
import com.hundunjiang.MbgServer.mapper.UserMapper;
import com.hundunjiang.MbgServer.mapper.VirtualAliasesMapper;
import com.hundunjiang.MbgServer.mapper.VirtualUsersMapper;
import com.hundunjiang.ToolsServer.server.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class EmailServiceImpl implements EmailService {

    @Autowired
    private VirtualAliasesMapper virtualAliasesMapper;

    @Autowired
    private VirtualUsersMapper virtualUsersMapper;

    @Autowired
    private UserMapper userMapper;

    /**
     * 邮箱注册
     * @param email 邮箱号
     * @param password 密码
     */
    @Override
    public boolean regist(String email, String password) {

        VirtualAliases virtualAliases=new VirtualAliases();
        virtualAliases.setDestination(email+"@hundunjiang.com");
        virtualAliases.setSource(email+"@hundunjiang.com");
        virtualAliases.setDomainId(1);
        virtualAliasesMapper.insertSelective(virtualAliases);
        VirtualUsers virtualUsers=new VirtualUsers();
        virtualUsers.setDomainId(1);
        virtualUsers.setEmail(email+"@hundunjiang.com");
        virtualUsers.setPassword(password);
        virtualUsersMapper.insertSelective(virtualUsers);
        return true;
    }
}
